<template>
  <div>
    <el-card>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-card shadow="never" style="box-shadow: none !important;">
            <div slot="header" class="clearfix">
              <span>日志信息设置</span>
            </div>

            <!-- 表单配置 -->
            <el-form ref="baseform" :model="form" label-width="180px">
              <el-form-item label="日志记录天数" prop="dbnet">
                <el-input v-model="form.SysLog_days" class="elInputS"></el-input>
              </el-form-item>
              <el-form-item label="是否允许导出日志">
                <el-radio v-model="form.SysLog_export_status" label="1">允许导出</el-radio>
                <el-radio v-model="form.SysLog_export_status" label="0">不允许导出</el-radio>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" v-permission="permission.edit" @click="onSubmit">确认</el-button>
                <el-button @click="onCancel">取消</el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { loginfo, logset } from '@/api/system/logset.js'
export default {
  data() {
    return {
      // 指令权限
      permission: {
        edit: ['admin', 'logset::edit']
      },
      textarea: '',
      // 表单字段
      form: {
        SysLog_days: '',
        SysLog_export_status: ''
      }
    }
  },
  created() {
    this.getloginfo()
  },
  methods: {
    getloginfo() {
      loginfo().then(res => {
        this.form = res.data.data
      })
    },
    onSubmit() {
      // 表单提交
      this.$refs.baseform.validate(valid => {
        if (!valid) return
        // 表单设置
        logset(this.form).then(res => {
          if (res.data.meta.status === 200) {
            this.$message.success('修改成功')
            this.getbaseinfo()
          }
        })
      })
    },
    onCancel() {
      this.$router.back(-1)
    }
  }
}
</script>

<style>
  .questionIco {
    cursor: pointer;
    padding-left: 20px;
    color: #EE9900;
    font-size: 16px;
  }
  .el-popper[x-placement^=right] .popper__arrow::after {
    border-right-color: #EE9900;
  }
</style>
